<template>
    <div>
        <h1>欢迎来到主页</h1>
        <el-row>
            <el-col :span="4">
                <RouterLink :to="{path:'/home/one',query:{id:classes[0].id}}">1</RouterLink>
            </el-col>
            <el-col :span="4">
                <RouterLink :to="{name:'two',params:{id:classes[1].id}}">2</RouterLink>
            </el-col>
        </el-row>
        
        
        <RouterView></RouterView>
    </div>
</template>

<script lang="ts">
import { defineComponent,reactive } from 'vue';
import { onBeforeRouteLeave } from 'vue-router';

export default defineComponent({
    setup () {
        
        const classes = reactive([
            {
                id:'01',
                name:'one',
                hobby:['打游戏','敲代码','睡觉'],
            },
            {
                id:'02',
                name:'two',
                hobby:['爱钱','旅游','明星'],
            },
        ]);
        onBeforeRouteLeave(()=>{
            console.log("借口");
            
        });
        return {
            classes,
        }
    }
})
</script>

<style scoped>

</style>